<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title>wifi</title>
    </head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" type="text/css" href="/assets/css/style.css">
    <style>
    </style>

    <body>
        <div class="main">
            <div class="input-box">
                <img src="/assets/img/sanjiao.png" class="logo"/>
                <div class="ximi">
                    <p class="en">XIMI NETWORK</p>
                    <p class="zh">西米宝贝成都网络科技有限公司</p>
                </div>
                <div class="line">
                    <label>会员编号</label>
                    <input type="text" class="text number"  value="">
                </div>
                <div class="line">
                    <label>手机号</label>
                    <input type="text" class="text mobile" maxlength="11"  value="">
                </div>
                <div class="upload-div">
                    <img src="/assets/img/table.png" class="upload up1"/>
                    <img src="/assets/img/card.png" class="upload up2"/>
                </div>
                <div class="submit">
                    <div class="image">
                        <input type="image" id="submit" src="/assets/img/submit.png" style="width: 80px;">
                    </div>
                </div>
                <div class="footer">
                    <p>温馨提示：根据国家工信部要求,必须提供使用者身份真实信息,上传信息后我们将在12小时内为您开通设备。</p>
                </div>
                </p>
            </div>
    </body>
    <script src="/assets/libs/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript">
        layui.use('upload', function () {
            var $ = layui.jquery, upload = layui.upload;
            upload.render({
                elem: '.up1'
                , url: '/index/ajax/upload/'
                , exts: 'png|jpg|jpeg'
                , size: 20480 //限制文件大小，单位 KB
                , done: function (res) {
                    if (res.code != 1 && res.msg) {
                        return layer.msg('上传失败');
                    }
                    $('.up1').attr('src', res.data.url);
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    return layer.msg('上传失败');
                }
            });
            upload.render({
                elem: '.up2'
                , url: '/index/ajax/upload/'
                , exts: 'png|jpg|jpeg'
                , size: 20480 //限制文件大小，单位 KB
                , done: function (res) {
                    if (res.code != 1 && res.msg) {
                        return layer.msg('上传失败');
                    }
                    $('.up2').attr('src', res.data.url)
                }
                , error: function () {
                    return layer.msg('上传失败');
                }
            });
            $('#submit').on('click', function () {
                auth_table = $('.up1').attr('src'), handheld_card = $('.up2').attr('src');
                number = $('.number').val(), mobile = $('.mobile').val();
                if (number == '' || number == undefined) {
                    layer.msg('请填写会员编号');
                    return false;
                }
                if (mobile == '' || mobile == undefined) {
                    layer.msg('请填手机号');
                    return false;
                }
                if (/^1[\d]{10}$/.test(mobile)==false) {
                    layer.msg('请填正确的手机号');
                    return false;
                }
                if (auth_table == '' || auth_table == undefined || auth_table == '/assets/img/table.png') {
                    layer.msg('请上传实名认证表格');
                    return false;
                }
                if (handheld_card == '' || handheld_card == undefined || handheld_card == '/assets/img/card.png') {
                    layer.msg('请上传手持身份证');
                    return false;
                }

                $.post('/index/user/uploadCard', {
                    'number': number,
                    'mobile': mobile,
                    'auth_table': auth_table,
                    'handheld_card': handheld_card
                }, function (rs) {
                    if (rs.code == 1) {
                        $('#submit').prop('disabled', true);
                        layer.msg('提交成功,我们将在12小时内为您开通设备', function () {
                            location.reload();
                        });
                    } else {
                        layer.msg('提交失败');
                    }
                })
            })
        });
    </script>
</html>